local fire_attack = fk.CreateSkill {
  name = "hanqing__pianxi__fire_attack_skill",
}

Fk:loadTranslationTable{
  ["hanqing__pianxi__fire_attack_skill"] = "火攻",
}

local DIY = require "packages/diy_utility/diy_utility"

fire_attack:addEffect("cardskill", {
  prompt = "#fire_attack_skill",
  target_num = 1,
  mod_target_filter = function(self, _, to_select, _, _, _)
    return not to_select:isKongcheng()
  end,
  target_filter = Util.CardTargetFilter,
  on_effect = function(self, room, effect)
    local from = effect.from
    local to = effect.to
    if to:isKongcheng() then return end

    local params = { ---@type AskToCardsParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = "fire_attack_skill",
      cancelable = false,
      pattern = ".|.|.|hand",
      prompt = "#fire_attack-show:" .. from.id
    }
    local showCard = room:askToCards(to, params)[1]
    local status1 = table.contains(DIY.getShownCards(to), showCard)
    to:showCards(showCard)

    showCard = Fk:getCardById(showCard)
    params = { ---@type AskToDiscardParams
      min_num = 1,
      max_num = 1,
      include_equip = false,
      skill_name = "fire_attack_skill",
      cancelable = true,
      pattern = ".|.|" .. showCard:getSuitString(),
      prompt = "#fire_attack-discard:" .. to.id .. "::" .. showCard:getSuitString(),
      skip = true,
    }
    local cards = room:askToDiscard(from, params)
    if #cards > 0 then
      local status2 = table.contains(DIY.getShownCards(from), cards[1])
      if not (status1 and status2) and (status1 or status2) then
        effect.additionalDamage = (effect.additionalDamage or 0) + 1
      end
      room:throwCard(cards, "fire_attack_skill", from, from)
      if not to.dead then
        room:damage({
          from = from,
          to = to,
          card = effect.card,
          damage = 1,
          damageType = fk.FireDamage,
          skillName = "fire_attack_skill",
        })
      end
    end
  end,
})

return fire_attack
